<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function deepCopy(target,cache =new Map()){
            if(target.typeOf !== 'object'){
                return target
            }
         
                if (cache.has(target)) {
          return cache.get(target)
       
            }
            let result = Array.isArray(target) ? [] : {};
            cache.set(target,result)
            if(Array.isArray(target)){
                for(var i= 0 ; i <target.length ; i++){
                    result.push(deepCopy(target))
                } 
            } else{
               for(var k in target){
                result[k] = deepCopy(target[k])
               }
            }
        }
        var obj1 = { name: '文理东', hobby: ['看书', '敲代码'], a: [1, 2] }

obj1.hobby.push(obj1.a)
obj1.a.push(obj1.hobby)

var obj2 = copyDeep(obj1)
console.log(obj2)
    </script>
</body>
</html>